#
#  SSF.OS.OSPF primary Makefile
#

SHELL = /bin/sh


RELEASE = 0.1.15

# ----- SETUP --------------------------------------------------------------- #

TOPDIR = ../../../..
include $(TOPDIR)/Makefile.common

JAVAC = javac -classpath $(SSFNET_TEST_CLASSPATH)
JAVA  = java  -classpath $(SSFNET_TEST_CLASSPATH)

# ----- MAKE ALL ------------------------------------------------------------ #

all:	ospf
	@echo '------- SSF.OS.OSPF BUILD COMPLETE --------'

# ----- MAKE OSPF ----------------------------------------------------------- #

ospf:
	$(JAVAC) *.java

# ----- MAKE TESTS ---------------------------------------------------------- #

tests:
	(cd test; $(MAKE))

# ----- MAKE VALID ---------------------------------------------------------- #

# runs validation tests tersely
valid:
	@(cd test; $(MAKE) valid)

# ----- MAKE JAVADOC -------------------------------------------------------- #

javadoc:
	javadoc -d doc/javadoc SSF.OS.OSPF
	@echo 'Java documentation for SSF.OS.OSPF can be found in doc/javadoc/'

# ----- MAKE CLEAN ---------------------------------------------------------- #

clean:
	@rm -f *.class
	@(cd test; $(MAKE) clean) > /dev/null 2>&1
	@echo 'Done.'

# ----- MAKE SPOTLESS ------------------------------------------------------- #

spotless:
	@find . \( -name "*.class" -o -name ".*~" -o -name "*~" \) -exec rm -f {} \;
	@rm -rf doc/javadoc/*
	@(cd test; $(MAKE) spotless) > /dev/null 2>&1
	@echo 'Done.'

# ----- MAKE DIST ----------------------------------------------------------- #

dist:
	@if [ -f ../sOSPF_$(RELEASE).tar.gz ]; \
	then echo ' *** ERROR: distribution file sOSPF_$(RELEASE).tar.gz already exists'; \
	else \
	  (cd ..; tar cpf sOSPF_$(RELEASE).tar \
	                    OSPF/Makefile \
	                    OSPF/README \
	                    OSPF/BinInt.java \
	                    OSPF/Debug.java \
	                    OSPF/Dijkstra.java \
	                    OSPF/Interface.java \
	                    OSPF/LSA.java \
	                    OSPF/LSDatabase.java \
	                    OSPF/LinkInfo.java \
	                    OSPF/Options.java \
	                    OSPF/Packet.java \
	                    OSPF/area_descriptor.java \
	                    OSPF/sOSPF.java \
	                    OSPF/package.html \
	                    OSPF/doc/HISTORY \
	                    OSPF/doc/index.html \
	                    OSPF/doc/validation.html \
	                    OSPF/doc/ospf-schema.dml \
	                    OSPF/test/Makefile \
	                    OSPF/test/dictionary.dml \
	                    OSPF/test/multi-single.html \
	                    OSPF/test/single-single.html \
	                    OSPF/test/share/campus1.dml \
	                    OSPF/test/share/campus1.gif \
	                    OSPF/test/share/campus1.pdf \
	                    OSPF/test/share/internet1.dml \
	                    OSPF/test/share/internet1.jpg \
	                    OSPF/test/share/internet1.pdf \
	                    OSPF/test/routertype1/Makefile \
	                    OSPF/test/routertype1/routertype1.html \
	                    OSPF/test/routertype1/routertype1.dml \
	                    OSPF/test/routertype1/routertype1-raw.out \
	                    OSPF/test/routertype1/routertype1.out \
	                    OSPF/test/routertype2/Makefile \
	                    OSPF/test/routertype2/routertype2.html \
	                    OSPF/test/routertype2/routertype2.dml \
	                    OSPF/test/routertype2/routertype2-raw.out \
	                    OSPF/test/routertype2/routertype2.out \
	                    OSPF/test/interfaces1/Makefile \
	                    OSPF/test/interfaces1/interfaces1.html \
	                    OSPF/test/interfaces1/interfaces1.dml \
	                    OSPF/test/interfaces1/interfaces1-raw.out \
	                    OSPF/test/interfaces1/interfaces1.out \
	                    OSPF/test/interfaces2/Makefile \
	                    OSPF/test/interfaces2/interfaces2.html \
	                    OSPF/test/interfaces2/interfaces2.dml \
	                    OSPF/test/interfaces2/interfaces2-raw.out \
	                    OSPF/test/interfaces2/interfaces2.out \
	                    OSPF/test/lsdb1/Makefile \
	                    OSPF/test/lsdb1/lsdb1.html \
	                    OSPF/test/lsdb1/lsdb1.dml \
	                    OSPF/test/lsdb1/lsdb1-raw.out \
	                    OSPF/test/lsdb1/lsdb1.out \
	                    OSPF/test/lsdb2/Makefile \
	                    OSPF/test/lsdb2/lsdb2.html \
	                    OSPF/test/lsdb2/lsdb2.dml \
	                    OSPF/test/lsdb2/lsdb2-raw.out \
	                    OSPF/test/lsdb2/lsdb2.out \
	                    OSPF/test/fwdtable1/Makefile \
	                    OSPF/test/fwdtable1/fwdtable1.html \
	                    OSPF/test/fwdtable1/fwdtable1.dml \
	                    OSPF/test/fwdtable1/fwdtable1-raw.out \
	                    OSPF/test/fwdtable1/fwdtable1.out \
	                    OSPF/test/fwdtable2/Makefile \
	                    OSPF/test/fwdtable2/fwdtable2.html \
	                    OSPF/test/fwdtable2/fwdtable2.dml \
	                    OSPF/test/fwdtable2/fwdtable2-raw.out \
	                    OSPF/test/fwdtable2/fwdtable2.out); \
	  echo; \
	  gzip -q ../sOSPF_$(RELEASE).tar; \
	  if [ -f ../sOSPF_$(RELEASE).tar.gz ]; \
	  then echo 'created distribution file ../sOSPF_$(RELEASE).tar.gz'; \
	  fi; \
	  echo; \
	  echo 'CHECKLIST FOR PREPARING A DISTRIBUTION:'; \
	  echo '   - change version # in this Makefile, doc/index.html'; \
          echo '     (several places), & doc/validation.html (if applicable)';\
	  echo '   - update doc/HISTORY file'; \
	fi
